let used = process.memoryUsage().heapUsed / 1024 / 1024;
console.log(`程序启动时占用内存: ${Math.round(used * 100) / 100} MB`);

global.gc();
used = process.memoryUsage().heapUsed / 1024 / 1024;
console.log(`启动后GC占用内存: ${Math.round(used * 100) / 100} MB`);

const weakMap = new WeakMap()

let rand = Math.random();
let N = 0;
for (let i = 0; i < 1000000; ++i) {
    test();
};
console.log(weakMap)

setTimeout(() => {
    console.log(N);
    used = process.memoryUsage().heapUsed / 1024 / 1024;
    console.log(`Promise创建后占用内存: ${Math.round(used * 100) / 100} MB`);

    global.gc();
    used = process.memoryUsage().heapUsed / 1024 / 1024;
    console.log(`GC后占用内存 ${Math.round(used * 100) / 100} MB`);
}, 10000);  // 上面的回调等待10毫秒，这里等待10秒，确保到这里回调肯定执行完成

// 测试函数
async function test(){
    weakMap.set({},123)
}